package sliver.dao.impl;

import java.io.Serializable;
import java.util.List;

import org.springframework.stereotype.Repository;

import sliver.dao.OrderDao;
import sliver.entity.Order;

@Repository
public class OrderDaoImpl extends BaseDaoImpl<Order> implements OrderDao{
	
	@Override
	public List<Order> findList(Serializable shopperId) {
		
		String queryString = "SELECT o FROM Order o WHERE o.shopper.id = ?";
		
		return complexQuery(queryString, new Object[]{shopperId});
	}
	
	@Override
	public Order findTagetOrder(Serializable orderId) {
		
		String queryString = "SELECT o FROM Order o WHERE o.id = ?";
		
		List<Order> orders = complexQuery(queryString, new Object[]{orderId});
		
		if(orders != null)
			return orders.get(0);
		
		return null;
	}
}
